package cn.itcast.hotel.mq;

import cn.itcast.hotel.constants.MqConstant;
import cn.itcast.hotel.service.IHotelService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @description:
 * @author: ajie
 * @date: 2024/4/13 21:52:38
 * @version: 1.0
 */
@Component
public class HotelListener {

    @Autowired
    private IHotelService hotelService;

    /**
     * @description: 监听酒店新增或修改的业务
     * @params: [id]
     * @return:
     * @author: ajie
     * @date: 2024/4/13 21:54
     */
    @RabbitListener(queues = MqConstant.HOTEL_INSERT_QUEUE)
    public void listenHotelInsertOrUpdate(Long id){
        hotelService.insertById(id);

    }

    /**
     * @description: 监听酒店删除的业务
     * @params: [id]
     * @return:
     * @author: ajie
     * @date: 2024/4/13 21:54
     */
    @RabbitListener(queues = MqConstant.HOTEL_DELETE_QUEUE)
    public void listenHotelDelete(Long id){
        hotelService.deleteById(id);

    }
}
